<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// 异步文件上传
Route::any("upload", "Controller@upload");
// 返回cropper页面
$this->get('cropper', function () {
    return view('cropper.cropper');
});

//接口相关
Route::group(['middleware' => 'apitoken'], function () {

    //站点请求数据接口
    $this->post("sendword", 'ApiController@sendWord');

    //站点请求成功异步告知接口
    $this->post("sendsuccess", 'ApiController@editList');
});

//    生成单词图片
$this->get('lookup/{word}/{watermark?}', 'ApiController@wordImage');

Auth::routes();
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function () {
    Route::get('/home', 'HomeController@index')->name('home');
//    单词页
    Route::get('/word/{slug?}', 'WordController@index')->name('word.index');
//    单词展示页
    Route::get('/w/{slug}/{word}', 'WordController@show')->name('word.show');
//    分类管理
    Route::get('/category', 'CategoryController@create')->name('category.create');
    Route::post('/category', 'CategoryController@store')->name('category.store');
    Route::patch('/category/{id}', 'CategoryController@update')->name('category.update');
    Route::delete('/category/{id}', 'CategoryController@destroy')->name('category.destroy');
//    开头结尾
    Route::get('/tse/{site?}', 'StartendController@create')->name('startend.create');
    Route::post('/tse', 'StartendController@store')->name('startend.store');
    Route::put('/tse/{id}', 'StartendController@update')->name('startend.update');
    Route::delete('/tse/{id}', 'StartendController@destroy')->name('startend.destroy');
//    单词关联分类
    Route::get('/words/category', 'WordController@create_category')->name('word.category.create');
    Route::post('/words/category', 'WordController@store_category')->name('word.category.store');
//    站点
    Route::resource('sites', 'SitesController');
//    模版
    $this->resource('template', 'TemplateController');
//    发文队列
    $this->resource('sendlist', 'SendlistController');
});